<?php
!defined('P_W') && exit('Forbidden');
class PW_House_ImageDataDB extends BaseDB {
	var $_tableName = "pw_house_imagedata";
	
	function get($imageid) {
		return $this->_db->get_one('SELECT * FROM '.$this->_tableName.' WHERE imageid='.pwEscape($imageid));
	}

	function insert($array) {
		$array	= $this->_checkData($array);
		if (!$array) {
			return null;
		}
		$this->_db->update('INSERT INTO '.$this->_tableName.' SET '.pwSqlSingle($array,false));
		return $this->_db->insert_id();
	}
	function update($imageid,$array){
		$array	= $this->_checkData($array);
		if (!$array) return null;
		$this->_db->update('UPDATE '.$this->_tableName.' SET '.pwSqlSingle($array,false).' WHERE imageid='.pwEscape($imageid));
	}
	function delete($imageid) {
		$this->_db->update('DELETE FROM '.$this->_tableName.' WHERE imageid='.pwEscape($imageid));
	}
	
	function getStruct() {
		return array('imageid','hits');
	}

	function _checkData($data){
		if (!is_array($data) || !count($data)) return null;
		$data = $this->_checkAllowField($data,$this->getStruct());

		return $data;
	}

}
?>